class Solution:
    def numPairsDivisibleBy60(self, time: List[int]) -> int:
        mod = 60
        ans = 0
        cnt = defaultdict(int)
        for i in range(len(time)):
            tmp = time[i] % mod
            ans += cnt[(mod - tmp) % mod]
            cnt[tmp]+=1
        return ans;
